#include <vector>

#include "CLexErrorMsg.h"
#include "CErrorStrings.h"

// Queda por mejorar: Comprobar que valor de err_id recibido tiene el valor adecuado, en vez de obviarlo.

// err_id debe ser LEX_UNEXPECTED_STRING_CHAR
CLexErrorMsg::CLexErrorMsg(error_id_type const err_id,char const car,std::string const& str)
    : error_id(LEX_UNEXPECTED_STRING_CHAR),
      str_aux(str),
      c(car),
      c_after(0)
{
}

// err_id debe ser LEX_UNEXPECTED_CHAR_AFTER
CLexErrorMsg::CLexErrorMsg(error_id_type const err_id,char const car,char const car_after)
    : error_id(LEX_UNEXPECTED_CHAR_AFTER),
      str_aux(),
      c(car),
      c_after(car_after)
{
}

// err_id debe ser LEX_UNEXPECTED_CHAR
CLexErrorMsg::CLexErrorMsg(error_id_type const err_id,char const car)
    : error_id(LEX_UNEXPECTED_CHAR),
      str_aux(),
      c(car),
      c_after(0)
{
}

char const* CLexErrorMsg::what()
    /* err[0]:string
       err[1][0]:car
       err[2][0]:car_after */
{
    std::vector<std::string> vct_error;
    vct_error.push_back(str_aux);

    std::string str_car;
    str_car = c;
    vct_error.push_back(str_car);
    str_car = c_after;
    vct_error.push_back(str_car);

    CErrorStrings* perr_strings(new CErrorStrings);
    perr_strings->GetErrorString(CErrorMsg::ERR_LEX,error_id,vct_error,str_error);
    delete perr_strings;
 
    return str_error.c_str();
}
